<script setup>
const router = useRouter();
const { personal, clearPersonal } = store.usePersonal();
if (!personal.code) {
  // router.replace('/login');
}
const logout = async () => {
  clearPersonal();
  router.push("/login");
}
</script>

<template>
  <div class="containerMain">
    <div v-if="!personal.code && 0" class="splash">数据正在准备中...</div>
    <div v-else class="screen">
      <el-header>
        <div class="titleContainer">
          <div class="left">
            <img src="@/img/login/logo.png" class="image" />
            <span>智慧电影管理系统</span>
          </div>
          <div class="right">
            <span style="font-size: 14px;margin-right:20px;">{{personal.name}}</span>
            <el-button @click="logout" type="text" size="small">退出登录</el-button>
          </div>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu :default-active="$route.path" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" @select="handleSelect_2" router>
            <el-menu-item index="/home">
              <el-icon><HomeFilled /></el-icon>
              <span slot="title">首页</span>
            </el-menu-item>
            <el-menu-item index="/member">
              <el-icon><UserFilled /></el-icon>
              <span slot="title">人员管理</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </div>
  </div>
</template>

<style lang='less' scoped>
.containerMain {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    min-width: 1600px;
}
.splash {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.el-header {
    padding-left: 10px;
    background-color: #ba2e2e;
    min-height: 50px;
    max-height: 50px;
}
.el-aside {
    background-color: #E9EEF3;
    color: #333;
    text-align: left;
    line-height: 200px;
}
.el-container {
    height: 100%;
}
.el-main {
    background-color: #FFF;
    color: #333;
    overflow: scroll;
    padding-bottom: 200px;
}
.titleContainer {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    font-size: 20px;
    color: #FFF;
}
.left {
    display: flex;
    flex-direction: row;
    align-items: center;
}
.image {
    width: 40px;
    margin-left: 10px;
    margin-right: 20px;
}
.right {
    width: 350px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    :global(.el-button--text) {
        color: #fff;
        background-color: #ba2e2e;
    }
}
</style>
